home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / GX Libraries / FramingLibrary.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-31  |  1.9 KB  |  54 lines  |  [TEXT/MPS ]

  1.  
  2. /*
  3.     File:        FramingLibrary.c
  4.  
  5.     Contains:    graphics libraries - Better gxShape framing routines
  6.  
  7.     Written by:    Cary Clark, Georgiann Delaney, Michael Fairman, Dave Good, Robert Johnson, Keith McGreggor, Mike Reed, Oliver Steele, David Van Brink, Chris Yerga
  8.  
  9.     Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  10.  
  11.     Change History (most recent first):
  12.  
  13.          <2>      1/9/95    JD        changed 'boolean' to 'Boolean'
  14.          <1>      1/9/95    JD        First checked in.
  15. */
  16.  
  17. #include "GraphicsLibraries.h"
  18.  
  19. void OutsetShape(gxShape source, Fixed outset)
  20. {
  21.     gxShape temp = GXCopyToShape(nil, source);
  22.     Boolean framed = GXGetShapeFill(source) < gxEvenOddFill;
  23.     GXSetShapeFill(source, gxWindingFill);
  24.     GXSetShapeFill(temp, gxClosedFrameFill);
  25.     GXSetShapeStyleAttributes(temp, gxCenterFrameStyle);
  26.     GXSetShapePen(temp, (outset < 0 ? -outset : outset) << 1);
  27.     GXPrimitiveShape(temp);
  28.     if (outset > 0)                         /* if we are outsetting */
  29.         GXUnionShape(source, temp);
  30.     else if (outset < 0)                        /* if we are insetting */
  31.         GXDifferenceShape(source, temp);
  32.     if (framed)
  33.         GXSetShapeFill(source, gxClosedFrameFill);
  34.     GXDisposeShape(temp);
  35. }
  36.  
  37. void FrameShape(gxShape source, Fixed outset)
  38. {
  39.     gxShape temp = GXCopyToShape(nil, source);
  40.     gxShapeFill originalFill = GXGetShapeFill(source);
  41.     GXSetShapeFill(temp, gxWindingFill);
  42.     GXSetShapeFill(source, gxClosedFrameFill);
  43.     GXSetShapeStyleAttributes(source, gxCenterFrameStyle);
  44.     GXSetShapePen(source, (outset < 0 ? -outset : outset) << 1);
  45.     GXPrimitiveShape(source);
  46.     if (outset > 0)                         /* if we are outside framing */
  47.         GXDifferenceShape(source, temp);
  48.     else if (outset < 0)                        /* if we are inside framing */
  49.         GXIntersectShape(source, temp);
  50.     else                                    /* the outset is 0 */
  51.         GXSetShapeFill(source, gxClosedFrameFill);
  52.     GXDisposeShape(temp);
  53. }
  54.